local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script,script.Parent.Base);
local ConnectClass=_G.CommonOHOH.load.Connect();

-- 车身
function M.new(...)
	return M(...);
end;

function M.ctor(self,...)--构造函数
	M.super.ctor(self,...);
	
end;

function M.dtor(self)
	M.super.dtor(self);
end;



function M.Assemble(self)

	self.Instance.Name = "Body"
	self.Instance.Parent = self.Car:GetModel()

	self.PointFolder=Instance.new("Folder",self.Instance)
	self.PointFolder.Name="Point"

	self.FlagPoint=self.Model:WaitForChild("Flag")
	self.FlagPoint.Parent=self.PointFolder
	self:Weld2Part(self.FlagPoint,self.Instance)

	self.TailPoint=self.Model:WaitForChild("Tail")
	self.TailPoint.Parent=self.PointFolder
	self:Weld2Part(self.TailPoint,self.Instance)

	self.WeaponPoint=self.Model:WaitForChild("Weapon")
	self.WeaponPoint.Parent=self.PointFolder
	self:Weld2Part(self.WeaponPoint,self.Instance)

	self.Ring=self.Model:WaitForChild("Ring")
	self.Ring.Parent=self.PointFolder

	self.RingList=self.Ring:GetChildren()

	for _,v in pairs(self.RingList) do
		self:Weld2Part(v,self.Ring)
	end
	self:Weld2Part(self.Ring,self.Instance)


	self.Player=self.Model:WaitForChild("Player")
	self.Player.Parent=self.PointFolder
	self.PlayerList=self.Player:GetChildren()

	for _,v in pairs(self.PlayerList) do
		self:Weld2Part(v,self.Player)
	end
	self:Weld2Part(self.Player,self.Instance)

	--将车身约束到引擎上
	local engine=self.Car:GetEngine()
	-- local engineBody=engine:CreateBody(self:GetEnginePivot())--创建动力引擎
    -- local weld = Instance.new("WeldConstraint",self.Instance)
	-- weld.Part0 = self.Instance
	-- weld.Part1 = engineBody
	self.Instance.Anchored=true
end

--获取装饰点位
function M.GetFlagPivot(self)
	return self.FlagPoint:GetPivot()
end

--获取推进器点位
function M.GetTailPivot(self)
	return self.TailPoint:GetPivot()
end

--获取钻头点位
function M.GetWeaponPivot(self)
	return self.WeaponPoint:GetPivot()
end

--获取轮胎点位
function M.GetRingPivot(self)
	local list={}
	for _,v in pairs(self.RingList) do
		table.insert(list,v:GetPivot())
	end
	return list
end

--获取引擎的位置
function M.GetEnginePivot(self)
	return self.Ring:GetPivot()
	
end



--获取玩家点位
function M.GetPlayerPivot(self)
	local list={}
	for _,v in pairs(self.PlayerList) do
		table.insert(list,v:GetPivot())
	end
	return list
end



function M.GetWeaponPostion(self)
	return self.WeaponPoint.CFrame.Position
end

function M.GetWeaponOrientation(self)
	return self.Instance.Orientation
end


return M